package com.tengniu.common.dto;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;

import java.io.Serializable;
import java.util.List;
import java.util.Objects;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class SearchReqDTO implements Serializable {

    private Integer pageNum;

    private Integer pageSize;

    /**
     * 公司类型
     */
    private List<Integer> companyType;

    /**
     * 关键字
     */
    private String queryWord;

    /**
     * 材料分类
     */
    private List<Integer> categoryId;

    /**
     * 品牌
     */
    private List<Integer> brandId;

    /**
     * 公司所在地
     */
    private List<String> CompanyLocationCodes;

    /**
     * 经营模式
     */
    private List<String> businessModelId;

    /**
     * 服务区域
     */
    private List<String> productLocationCodes;

    /**
     * 注册资金条件id
     */
    private RegisteredCapital registeredCapital;

    /**
     * 注册资金条件
     */
    @Data
    @AllArgsConstructor
    @NoArgsConstructor
    public static class RegisteredCapital implements Serializable {

        //最小注册资金
        private Integer minRegisteredCapital;

        //最大注册资金
        private Integer maxRegisteredCapital;

    }

    /**
     * 判断查询条件是否为空
     * @return
     */
    public boolean isNull() {
        return StringUtils.isBlank(this.queryWord)
                && CollectionUtils.isEmpty(this.categoryId)
                && CollectionUtils.isEmpty(this.brandId)
                && CollectionUtils.isEmpty(this.CompanyLocationCodes)
                && CollectionUtils.isEmpty(this.businessModelId)
                && CollectionUtils.isEmpty(this.productLocationCodes)
                && Objects.isNull(this.registeredCapital)
                && CollectionUtils.isEmpty(this.companyType);
    }
}
